﻿using System;
using System.Collections.Generic;
using ProjScan.Config;
using ProjScan.Config.GUIConfig;
using ProjScan.ScanGUI.Tools;
using ProjScan.Tools;
using UnityEngine;

namespace ProjScan.ScanGUI.Page
{
	// Token: 0x02000267 RID: 615
	internal abstract class BasePage<T> : IPage where T : BaseConfig, new()
	{
		// Token: 0x060010A0 RID: 4256 RVA: 0x00008080 File Offset: 0x00006280
		public BasePage()
		{
			this.data = (Singleton<ConfigMgr>.Instance.GetConfig<T>() as T);
			this.ruleGUIs = new List<RuleGUI>();
		}

		// Token: 0x060010A1 RID: 4257 RVA: 0x0004C528 File Offset: 0x0004A728
		protected virtual void CreateRuleGUI()
		{
			bool flag = true;
			foreach (KeyValuePair<string, RuleConfig> keyValuePair in this.data.dicRuleConfig)
			{
				RuleInfo ruleInfo = default(RuleInfo);
				bool flag2 = !this.dicRuleInfo.TryGetValue(keyValuePair.Key, out ruleInfo);
				if (flag2)
				{
					Debug.LogError(" 没有找到规则的详细信息");
				}
				bool hasSeparateTargetDirSettings = this.data.hasSeparateTargetDirSettings;
				RuleGUI ruleGUI;
				if (hasSeparateTargetDirSettings)
				{
					ruleGUI = new RuleGUI();
					ruleGUI.fixModule = this.fixModule;
					ruleGUI.ruleKey = keyValuePair.Key;
					ruleGUI.checkEnabled = keyValuePair.Value.checkEnabled;
					ruleGUI.fixEnabled = keyValuePair.Value.fixEnabled;
					ruleGUI.hasSrcPath = keyValuePair.Value.hasSrcPath;
					ruleGUI.isSeparateDirSettingsEnabled = keyValuePair.Value.isSeparateDirSettingsEnabled;
					ruleGUI.targetConfig = new List<ScanAssetsConfig>(keyValuePair.Value.targetConfig);
					ruleGUI.ignoreConfig = new List<ScanAssetsConfig>(keyValuePair.Value.ignoreConfig);
					ruleGUI.ruleName = ruleInfo.ruleName;
					ruleGUI.description = ruleInfo.Description;
					ruleGUI.thresholdDescription = ruleInfo.ThresholdDescription;
					ruleGUI.thresholdDefault = ruleInfo.ThresholdDefault;
					ruleGUI.thresholdCompare = ruleInfo.ThresholdCompare;
					ruleGUI.RulePriority = ruleInfo.RulePriority;
					ruleGUI.hasWhiteList = this.data.hasWhiteList;
					ruleGUI.hasfailedData = this.data.hasfailedData;
					ruleGUI.hasFixRule = this.data.hasFixRule;
					ruleGUI.hasSeparateTargetDirSettings = true;
				}
				else
				{
					ruleGUI = new RuleGUI();
					ruleGUI.fixModule = this.fixModule;
					ruleGUI.ruleKey = keyValuePair.Key;
					ruleGUI.checkEnabled = keyValuePair.Value.checkEnabled;
					ruleGUI.fixEnabled = keyValuePair.Value.fixEnabled;
					ruleGUI.hasSrcPath = keyValuePair.Value.hasSrcPath;
					ruleGUI.hasWhiteList = this.data.hasWhiteList;
					ruleGUI.hasfailedData = this.data.hasfailedData;
					ruleGUI.hasFixRule = this.data.hasFixRule;
					ruleGUI.ruleName = ruleInfo.ruleName;
					ruleGUI.description = ruleInfo.Description;
					ruleGUI.RulePriority = ruleInfo.RulePriority;
					ruleGUI.hasSeparateTargetDirSettings = false;
				}
				bool flag3 = flag;
				if (flag3)
				{
					ruleGUI.isShowRuleSetting = true;
					flag = false;
				}
				this.ruleGUIs.Add(ruleGUI);
			}
		}

		// Token: 0x060010A2 RID: 4258 RVA: 0x0004C800 File Offset: 0x0004AA00
		protected virtual void GUITitle(bool hasFixRule)
		{
			GUILayout.BeginHorizontal(new GUILayoutOption[]
			{
				GUILayout.Width(this.rect.width - GUI.skin.verticalScrollbarDownButton.fixedWidth)
			});
			GUITools.DrawLable_FontSize16_Bold(" 规则列表：");
			bool flag = GUILayout.Button("打开全部检测", Singleton<GUIStyleManager>.Instance.GetBasicStyle(TBasicStyle.button), new GUILayoutOption[]
			{
				GUILayout.Width(120f)
			});
			if (flag)
			{
				foreach (RuleGUI ruleGUI in this.ruleGUIs)
				{
					ruleGUI.checkEnabled = true;
					RuleConfig value = this.data.dicRuleConfig[ruleGUI.ruleKey];
					value.checkEnabled = true;
					this.data.dicRuleConfig[ruleGUI.ruleKey] = value;
				}
			}
			bool flag2 = GUILayout.Button("关闭全部检测", Singleton<GUIStyleManager>.Instance.GetBasicStyle(TBasicStyle.button), new GUILayoutOption[]
			{
				GUILayout.Width(120f)
			});
			if (flag2)
			{
				foreach (RuleGUI ruleGUI2 in this.ruleGUIs)
				{
					ruleGUI2.checkEnabled = false;
					RuleConfig value2 = this.data.dicRuleConfig[ruleGUI2.ruleKey];
					value2.checkEnabled = false;
					this.data.dicRuleConfig[ruleGUI2.ruleKey] = value2;
				}
			}
			GUILayout.FlexibleSpace();
			if (hasFixRule)
			{
				bool flag3 = GUILayout.Button("打开全部修复", Singleton<GUIStyleManager>.Instance.GetBasicStyle(TBasicStyle.button), new GUILayoutOption[]
				{
					GUILayout.Width(120f)
				});
				if (flag3)
				{
					foreach (RuleGUI ruleGUI3 in this.ruleGUIs)
					{
						ruleGUI3.fixEnabled = true;
						RuleConfig value3 = this.data.dicRuleConfig[ruleGUI3.ruleKey];
						value3.fixEnabled = true;
						this.data.dicRuleConfig[ruleGUI3.ruleKey] = value3;
					}
				}
				bool flag4 = GUILayout.Button("关闭全部修复", Singleton<GUIStyleManager>.Instance.GetBasicStyle(TBasicStyle.button), new GUILayoutOption[]
				{
					GUILayout.Width(120f)
				});
				if (flag4)
				{
					foreach (RuleGUI ruleGUI4 in this.ruleGUIs)
					{
						ruleGUI4.fixEnabled = false;
						RuleConfig value4 = this.data.dicRuleConfig[ruleGUI4.ruleKey];
						value4.fixEnabled = false;
						this.data.dicRuleConfig[ruleGUI4.ruleKey] = value4;
					}
				}
			}
			GUILayout.EndHorizontal();
			for (int i = 0; i < this.ruleGUIs.Count; i++)
			{
				DrawRuleState.Initialize(1);
				this.ruleGUIs[i].DrawGUI(this.rect.width - GUI.skin.verticalScrollbarDownButton.fixedWidth);
				bool flag5 = DrawRuleState.EndRule(1);
				if (flag5)
				{
					bool hasSeparateTargetDirSettings = this.data.hasSeparateTargetDirSettings;
					if (hasSeparateTargetDirSettings)
					{
						RuleConfig value5 = this.data.dicRuleConfig[this.ruleGUIs[i].ruleKey];
						value5.checkEnabled = this.ruleGUIs[i].checkEnabled;
						value5.fixEnabled = this.ruleGUIs[i].fixEnabled;
						value5.isSeparateDirSettingsEnabled = this.ruleGUIs[i].isSeparateDirSettingsEnabled;
						value5.ignoreConfig = this.ruleGUIs[i].ignoreConfig.ToArray();
						value5.targetConfig = this.ruleGUIs[i].targetConfig.ToArray();
						this.data.dicRuleConfig[this.ruleGUIs[i].ruleKey] = value5;
					}
					else
					{
						RuleConfig value6 = this.data.dicRuleConfig[this.ruleGUIs[i].ruleKey];
						value6.checkEnabled = this.ruleGUIs[i].checkEnabled;
						value6.fixEnabled = this.ruleGUIs[i].fixEnabled;
						this.data.dicRuleConfig[this.ruleGUIs[i].ruleKey] = value6;
					}
				}
			}
		}

		// Token: 0x040009D6 RID: 2518
		protected T data;

		// Token: 0x040009D7 RID: 2519
		protected List<RuleGUI> ruleGUIs;
	}
}
